package cn.hchaojie.camp.javafx.binding;

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.TextArea;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class TextAreaBinding extends Application {

	@Override
	public void start(Stage stage) throws Exception {
		Scene scene = new Scene(createContents());
		
		stage.setScene(scene);
		stage.show();
	}
	
	// 在这里创建页面布局
	private Parent createContents() {
		VBox vbox = new VBox(10);
		vbox.setPadding(new Insets(10));
		
		TextArea t1 = new TextArea();
		TextArea t2 = new TextArea();
		
		t1.textProperty().bindBidirectional(t2.textProperty());
		
		vbox.getChildren().addAll(t1, t2);

		return vbox;
	}

	public static void main(String[] args) {
		launch(args);
	}
}
